//容量为m的小根堆 比堆顶大就压入
#include <cstdio>
#include <vector>
#include <queue>
#include <functional>
using namespace std;
#define DEBUG
int m, n;
bool cmp(int x1, int x2)
{
}
// priority_queue<int, vector<int>, [&](int x1, int x2)
// {
//     return x1>x2;
// }> heap;
priority_queue<int, vector<int>, greater<int>()> heap;
int main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
        freopen("./out.txt", "w", stdout);
    #endif
    scanf("%d%d", &n, &m);
    for(int i=1; i<=m; i++)
    {
        int x; scanf("%d", &x);
        heap.push(x);
    }
    
    for(int i=m+1; i<=n; i++)
    {
        int x; scanf("%d", &x);
        if(x>heap.top()) heap.pop();
        heap.push(x);
    }
    printf("%d\n", heap.top());
    return 0;
}